package cn.audit.service.log;

import cn.audit.bean.dto.UserCorrelation;
import cn.audit.bean.pojo.WorkLog;
import cn.audit.repository.log.WorkLogRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
 * @Author: 李忆枫
 * @Date: 2019/5/23 17:20
 */
@Service
public class WorkLogService {

    @Resource
    private WorkLogRepository workLogRepository;

    public List<UserCorrelation> findWorkLog(String name, String submissiondate) {
        return workLogRepository.findWorkLog(name, submissiondate);
    }

    @Transactional(rollbackFor = Exception.class)
    public void save(WorkLog workLog) {
        workLogRepository.save(workLog);
    }

    @Transactional(rollbackFor = Exception.class)
    public void batchDelete(List<Long> ids) {
        workLogRepository.batchDelete(ids);
    }

    /**
     * 根据id查找
     *
     * @param id
     * @return
     */
    public WorkLog findById(Long id) {
        Optional<WorkLog> op = workLogRepository.findById(id);
        return op.get();
    }


}
